home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
util
/
pack
/
xpk_Source.lha
/
xpk_Source
/
xpkmaster
/
debug.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-11-18
|
7KB
|
209 lines
#ifndef XPKMASTER_DEBUG_C
#define XPKMASTER_DEBUG_C
/* Routinesheader
Name: debug.c
Main: xpkmaster
Versionstring: $VER: debug.c 1.9 (18.11.1998)
Author: SDI
Distribution: Freeware
Description: the debug stuff
1.0 05.10.96 : first real version
1.1 20.10.96 : added the external debug modes
1.2 21.10.96 : changed debug totally
1.3 01.01.97 : changed output a bit - "XpkM before stuff - find in lots
of other debuf stuff"
1.4 09.03.97 : output contained 0 byte - removed
1.5 01.04.97 : little changes
1.6 12.04.97 : added TagList output, therefor changed XPKDEBUG contents
1.7 21.02.98 : uses new style register definition
1.8 25.06.98 : now uses SDI_compiler.h
1.9 18.11.98 : new style tag output copied from xadmaster.library
*/
#include <exec/types.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include <utility/tagitem.h>
#include <dos/var.h>
#include <xpk/xpk.h>
#include "xpkmaster.h"
#include "SDI_compiler.h"
typedef void (*putchtype) ();
#define FLAG_ERROR (1<<0)
#define FLAG_RUNTIME (1<<1)
#define FLAG_TAGLIST (1<<2)
extern LONG STDARGS KPutChar(LONG);
extern LONG STDARGS DPutChar(LONG);
extern void DoDebug(UBYTE mode, STRPTR fmt, APTR data);
static ASM(void) serfunc(REG(d0, UBYTE c), REG(a3, ULONG pd))
{ if(c) KPutChar(c); }
static ASM(void) parfunc(REG(d0, UBYTE c), REG(a3, ULONG pd))
{ if(c) DPutChar(c); }
static ASM(void) normfunc(REG(d0, UBYTE c), REG(a3, ULONG pd))
{
UBYTE d = c;
if(c)
Write(pd, &d, 1);
}
void DebugTagList(STRPTR fmt, struct TagItem *taglist)
{
DoDebug(FLAG_TAGLIST, fmt, taglist);
}
void DebugError(STRPTR format, ...)
{
DoDebug(FLAG_RUNTIME, format, (APTR)((ULONG)(&format)+sizeof(STRPTR)));
}
void DebugRunTime(STRPTR format, ...)
{
DoDebug(FLAG_ERROR, format, (APTR)((ULONG)(&format)+sizeof(STRPTR)));
}
void DoDebug(UBYTE mode, STRPTR fmt, APTR data)
{
ULONG fh = 0, i, Flags = 0;
UBYTE Mode[5] = "";
ASM(void) (*function)(REG(d0, UBYTE), REG(a3, ULONG)) = 0;
Forbid();
GetVar("XPKDEBUG", (STRPTR) &Mode, 5, GVF_GLOBAL_ONLY);
for(i=1; Mode[i] && i < 5; ++i)
{
switch(Mode[i])
{
case 'E': Flags |= FLAG_ERROR; break;
case 'R': Flags |= FLAG_RUNTIME; break;
case 'T': Flags |= FLAG_TAGLIST; break;
}
}
mode &= Flags;
if(mode)
{
switch(Mode[0])
{
case 'S': function = serfunc; break;
case 'P': function = parfunc; break;
case 'F':
if((fh = Open("T:XpkMasterOut", MODE_READWRITE)))
{
Seek(fh, 0, OFFSET_END);
function = normfunc;
}
break;
}
if(function)
{
i = (ULONG) FindTask(0);
RawDoFmt("XpkM(%08lx):", &i, (putchtype) function, (APTR) fh);
RawDoFmt(fmt, data, (putchtype) function, (APTR) fh);
RawDoFmt("\n", 0, (putchtype) function, (APTR) fh);
if(mode & FLAG_TAGLIST)
{
struct TagItem *ti;
while((ti = NextTagItem((struct TagItem **) &data)))
{
ULONG i[2], dmode = 0;
STRPTR s;
/* dmode == 1 - BOOL data, dmode == 2 - unknown */
switch(ti->ti_Tag)
{
case XPK_InName: s = "XPK_InName, \"%s\" ($%08lx)"; break;
case XPK_InFH: s = "XPK_InFH, $%08lx"; break;
case XPK_InBuf: s = "XPK_InBuf, $%08lx"; break;
case XPK_InHook: s = "XPK_InHook, $%08lx"; break;
case XPK_OutName: s = "XPK_OutName, \"%s\" ($%08lx)"; break;
case XPK_OutFH: s = "XPK_OutFH, %08lx"; break;
case XPK_OutBuf: s = "XPK_OutBuf, $%08lx"; break;
case XPK_GetOutBuf: s = "XPK_GetOutBuf, $%08lx"; break;
case XPK_OutHook: s = "XPK_OutHook, $%08lx"; break;
case XPK_InLen: s = "XPK_InLen, %lu"; break;
case XPK_OutBufLen: s = "XPK_OutBufLen, %lu"; break;
case XPK_GetOutLen: s = "XPK_GetOutLen, $%08lx"; break;
case XPK_GetOutBufLen: s = "XPK_GetOutBufLen, $%08lx"; break;
case XPK_Password: s = "XPK_Password, \"%s\" ($%08lx)"; break;
case XPK_GetError: s = "XPK_GetError, $%08lx"; break;
case XPK_OutMemType: s = "XPK_OutMemType, $%08lx"; break;
case XPK_PassThru: s = "XPK_PassThru, %s"; dmode = 1; break;
case XPK_StepDown: s = "XPK_StepDown, %s"; dmode = 1; break;
case XPK_ChunkHook: s = "XPK_ChunkHook, $%08ld"; break;
case XPK_PackMethod: s = "XPK_PackMethod, \"%s\" ($%08lx)"; break;
case XPK_ChunkSize: s = "XPK_ChunkSize, %lu"; break;
case XPK_PackMode: s = "XPK_PackMode, %lu"; break;
case XPK_NoClobber: s = "XPK_NoClobber, %s"; dmode = 1; break;
case XPK_Ignore: s = "XPK_Ignore"; break;
case XPK_TaskPri: s = "XPK_TaskPri, $ld"; break;
case XPK_FileName: s = "XPK_FileName, \"%s\" ($%08lx)"; break;
case XPK_ShortError: s = "XPK_ShortError, %s"; dmode = 1; break;
case XPK_PackersQuery: s = "XPK_PackersQuery, $%08lx"; break;
case XPK_PackerQuery: s = "XPK_PackerQuery, $%08lx"; break;
case XPK_ModeQuery: s = "XPK_ModeQuery, $%08lx"; break;
case XPK_LossyOK: s = "XPK_LossyOK, %s"; dmode = 1; break;
case XPK_NoCRC: s = "XPK_NoCRC, $%08lx"; break;
case XPK_Key16: s = "XPK_Key32, $%04lx"; break;
case XPK_Key32: s = "XPK_Key32, $%08lx"; break;
case XPK_NeedSeek: s = "XPK_NeedSeek, %s"; dmode = 1; break;
case XPK_UseXfdMaster: s = "XPK_UseXfdMaster, %s"; dmode = 1; break;
case XPK_UseExternals: s = "XPK_UseExternals, %s"; dmode = 1; break;
case XPK_PassRequest: s = "XPK_PassRequest, %s"; dmode = 1; break;
case XPK_Preferences: s = "XPK_Preferences, %s"; dmode = 1; break;
case XPK_ChunkReport: s = "XPK_ChunkReport, %s"; dmode = 1; break;
case XPK_PassChars: s = "XPK_PassChars, $%08lx"; break;
case XPK_PasswordBuf: s = "XPK_PasswordBuf, $%08lx"; break;
case XPK_PassBufSize: s = "XPK_PassBufSize, %lu"; break;
case XPK_Key16BitPtr: s = "XPK_Key16BitPtr, $%08lx"; break;
case XPK_Key32BitPtr: s = "XPK_Key32BitPtr, $%08lx"; break;
case XPK_PubScreen: s = "XPK_PubScreen, $%08lx"; break;
case XPK_PassTitle: s = "XPK_PassTitle, \"%s\" ($%08lx)"; break;
case XPK_TimeOut: s = "XPK_TimeOut, %lu"; break;
case XPK_PassWinLeft: s = "XPK_PassWinLeft, %lu"; break;
case XPK_PassWinTop: s = "XPK_PassWinTop, %lu"; break;
case XPK_PassWinWidth: s = "XPK_PassWinWidth, %lu"; break;
case XPK_PassWinHeight: s = "XPK_PassWinHeight, %lu"; break;
case XPK_PassCenter: s = "XPK_PassCenter, %s"; dmode = 1; break;
case XPK_PassVerify: s = "XPK_PassVerify, %s"; dmode = 1; break;
default: s = "$%08lx, $%08lx"; dmode = 2; break;
}
if(dmode == 1)
i[0] = ti->ti_Data ? (ULONG) "TRUE" : (ULONG) "FALSE";
else if(dmode == 2)
{
i[0] = ti->ti_Tag; i[1] = ti->ti_Data;
}
else
i[0] = i[1] = ti->ti_Data;
RawDoFmt(" ", 0, (putchtype) function, (APTR) fh);
RawDoFmt(s, i, (putchtype) function, (APTR) fh);
RawDoFmt("\n", 0, (putchtype) function, (APTR) fh);
}
RawDoFmt(" TAG_DONE\n", 0, (putchtype) function, (APTR) fh);
}
}
if(fh)
Close(fh);
}
Permit();
}